package com.sinoglobal.sinostore.widget.view;

import android.content.Context;
import android.support.v4.view.VerticalViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by XINDZ on 2017/2/8.
 * 功能:解决 因为嵌套导致的pointerIndex out of range
 */

public class TryViewPager extends VerticalViewPager {
    public TryViewPager(Context context) {
        super(context);
    }

    public TryViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        try {
            return super.onTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        try {
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }
//
//    @Override
//    public boolean onInterceptTouchEvent(MotionEvent arg0) {
//        boolean b = false;
//        try {
//            b = super.onInterceptTouchEvent(arg0);
//        } catch (Exception e) {
//
//        }
//        return b; //网上看的方法是直接返回false，但是会导致ViewPager翻页有BUG
//    }
//
//    @Override
//    public boolean onTouchEvent(MotionEvent arg0) {
//        try {
//            super.onTouchEvent(arg0);
//        } catch (Exception e) {
//
//        }
//        return false;
//    }
}
